#include <stdio.h>
#include <stdarg.h>

double vasum(int sw, ...)
{
    double sum= 0;
    va_list ap;

    va_start(ap, sw);

    sum += va_arg(ap, int);
    switch (sw) {
        case 0:
            sum += va_arg(ap, int);
            break;

        case 1:
            sum += va_arg(ap, long);
            break;

        case 2:
            sum += va_arg(ap, long);
            sum += va_arg(ap, double);
    }

    va_end(ap);
    return sum;
}

int main(void)
{

    printf("10 + 2\t\t=%.2f\n", vasum(0, 10, 2));
    printf("57 + 300000L\t=%.2f\n", vasum(1, 57, 300000L));
    printf("98 + 2L + 3.14\t=%.2f\n", vasum(2, 98, 2L, 3.14));

    return 0;
}
